package com.lsh.payment.core.service.refund.impl;

import com.alibaba.fastjson.JSONObject;
import com.lsh.payment.api.model.refund.RefundRequest;
import com.lsh.payment.core.model.payenum.PayChannel;
import com.lsh.payment.core.model.refund.PayRefund;
import com.lsh.payment.core.service.refund.IRefundBuilder;
import com.lsh.payment.core.service.refund.IRefundDirector;

/**
 * Project Name: lsh-payment
 *
 * @author peter
 * @date 18/7/10
 * 北京链商电子商务有限公司
 * Package
 * desc:
 */
public class RefundDirector implements IRefundDirector {

    private IRefundBuilder refundBuilder;

    public RefundDirector(IRefundBuilder refundBuilder) {
        this.refundBuilder = refundBuilder;
    }

    @Override
    public PayRefund getPayRefund(RefundRequest refundRequest, PayChannel payChannel) {
        PayRefund payRefund = refundBuilder.builderRefundOrder(refundRequest, payChannel);

        JSONObject refundExtJson = refundBuilder.builderRefundExt(refundRequest);

        payRefund.setExt(refundExtJson.toJSONString());

        return payRefund;
    }
}
